﻿import QtQuick 2.10
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

Rectangle{
    color: "#F4F4F4"
    radius: 20
    signal signalTextFiledFocus(bool isFocus);
    signal signalTextChanged(string text);
    MouseArea{
        id:ma2
        anchors.fill: parent
        onClicked: {
            console.log("clicked------------",focus);
            signalTextFiledFocus(focus)
        }
    }
    TextField {
        id:searchBox
        placeholderText: qsTr("凉生 我们可不可以不忧伤")
        anchors.fill: parent
        anchors.leftMargin: 10
        anchors.rightMargin: 10
        style: TextFieldStyle {
            textColor: "#333333"
            background: Item {
                implicitWidth: 100
                implicitHeight: 24
            }
        }
        onFocusChanged: {
            signalTextFiledFocus(focus)
        }
        onTextChanged: {
            console.log("text ",text);
            signalTextChanged(text);
        }
    }
    Rectangle{
        id:btn
        width: searchBox.height-10
        height: width
        anchors.verticalCenter: searchBox.verticalCenter
        anchors.right: parent.right
        anchors.rightMargin: 10
        radius: 10
        color: "#333333"
        MouseArea{
            id:ma
            anchors.fill: parent
            onClicked: {
                console.log("开始搜索: ",searchBox.text);
            }
        }
    }

    function updateFocus(focus){
        searchBox.focus  = focus;
    }
}
